use crate::lexer::clj_code_to_chars::CljCharIterator;

#[derive(Debug)]
pub enum NumberType {
    Integer {vs_i: i64},
    Double {vs_f: f64},
    Invalid,
}

pub fn check_number_type(s: &str) -> NumberType {
    let trimmed = s.trim();
    if trimmed.is_empty() {
        return NumberType::Invalid;
    }
    // 尝试解析为整数（如 i64）
    if trimmed.parse::<i64>().is_ok() {
        return NumberType::Integer{vs_i: trimmed.parse::<i64>().unwrap()};
    }
    // 尝试解析为双精度浮点数（如 f64）
    if trimmed.parse::<f64>().is_ok() {
        return NumberType::Double{vs_f: trimmed.parse::<f64>().unwrap()};
    }
    NumberType::Invalid
}

// let result = check_number_type(s);
// match result {
// NumberType::Integer{vs} => println!("{:?}", vs),
// NumberType::Double{vs} => println!("{:?}", vs),
// NumberType::Invalid => println!("{:?}", "Invalid"),
// }

// 定义一个不可实例化的结构体，当做静态类
pub struct CljUtil;

impl CljUtil {

    pub fn to_str(xs: &str) -> &str {
        return "";
    }

    pub fn get_string<'a>(my_char_iterator: &'a mut CljCharIterator<'a>) -> Result<String, &'a str> {
        let mut sb = String::new();
        // 移动到 " 的后一个字符
        my_char_iterator.next();
        loop {
            let c: char = my_char_iterator.current();
            if c == '"' {
                return Ok(sb);
            } else if c == '\n' {
                //return Err("string not terminated: ".to_owned() + CljUtil::toStr(sb));
                return Err("string not terminated ");
            }

            sb.push(c);
            my_char_iterator.next();
        }
    }
}


















































